{{ $description := (site.Params.description) }}
{{ with (.Summary) }}{{ $description = . }}{{ end }}
{{ with (.Description) }}{{ $description = . }}{{ end }}

{{ $pages := (where (site.RegularPages) "Section" "in" (site.Params.content.sections)) }}
{{ $pages = (($pages) | first 100) }}

{{ ((printf "<?xml version='1.0' encoding='UTF-8'?>") | safeHTML) }}
<rss version="2.0"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:yandex="http://news.yandex.ru"
     xmlns:turbo="http://turbo.yandex.ru">
  <channel>
    <title>{{ (site.Title) }}</title>
    <link>{{ (.Permalink) }}</link>
    <description>{{ ($description) }}</description>
      {{ with (site.LanguageCode) }}
        <language>{{ . }}</language>
      {{ end }}
      {{ range ($pages) }}
        <item turbo="true">
          <title>{{ (.Title) }}</title>
          <link>{{ (.Permalink) }}</link>
          <pubDate>{{ (.Date.UTC.Format "Mon, 02 Jan 2006 15:04:05 -0700") }}</pubDate>
            {{ range (.Params.authors) }}
                {{ with (site.GetPage "taxonomyTerm" (printf "authors/%s" (urlize .))) }}
                    {{ if (.Params.email) }}
                      <author>{{ (.Params.email) }} ({{ (.Title) }})</author>
                    {{ else }}
                      <dc:creator>{{ (.Title) }}</dc:creator>
                    {{ end }}
                {{ end }}
            {{ end }}
            {{ if .Params.categories }}
                {{ range (.GetTerms "categories") }}
                  <category>{{ (.Title) }}</category>
                {{ end }}
            {{ else }}
                {{ range (.GetTerms "tags") }}
                  <category>{{ (.Title) }}</category>
                {{ end }}
            {{ end }}
            {{ $related := ((where (site.RegularPages.Related .) "Type" "in" (.Type)) | first 30) }}
            {{ with ($related) }}
              <yandex:related>
                  {{ range . }}
                    <link url="{{ (.Permalink) }}">{{ (.Title) }}</link>
                  {{ end }}
              </yandex:related>
            {{ end }}
          <turbo:extendedHtml>true</turbo:extendedHtml>
          <turbo:source>{{ (.Permalink) }}</turbo:source>
          <turbo:topic>{{ (.Title) }}</turbo:topic>
          <turbo:content>{{ ((printf "<![CDATA[%s]]>" (.Content)) | safeHTML) }}</turbo:content>
        </item>
      {{ end }}
  </channel>
</rss>
